﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StartSubMenu
{
    public partial class AddSubMenuForm : Form
    {
        private string _title = "";
        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }

        private string _icon = null;
        public string IconPath
        {
            get { return _icon; }
            set { _icon = value; }
        }

        //--------------------------------------------------------------------------------
        public AddSubMenuForm()
        {
            InitializeComponent();
            this.DialogResult = DialogResult.Cancel;
        }
        //--------------------------------------------------------------------------------
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Icon (*.ico)|*.ico|Executable (*.exe)|*.exe";
            if (ofd.ShowDialog() != DialogResult.OK)
                return;

            _icon = ofd.FileName;
            picbox.Image = Icon.ExtractAssociatedIcon(ofd.FileName).ToBitmap();
        }
        //--------------------------------------------------------------------------------
        private void btnDone_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim() == "" || _icon == "")
                MessageBox.Show("Name or icon cannot be empty");

            _title = txtName.Text;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        //--------------------------------------------------------------------------------
    }
}
